﻿using System;
using Eg.Core;
using NHibernate;

namespace NamedQueryExample
{

    public class Queries
    {

        private readonly ISession _session;

        public Queries(ISession session)
        {
            if (session == null)
                throw new ArgumentNullException("session");
            _session = session;
        }

        public Book GetBookByISBN(string isbn)
        {
            return _session
                .GetNamedQuery("GetBookByISBN")
                .SetString("isbn", isbn)
                .UniqueResult<Book>();
        }

    }

}
